package com.juyu.miliao.api.dao.mysql;

import com.juyu.miliao.api.domain.UserMessageSettings;
import com.juyu.miliao.common.dataSource.tool.operate.Operate;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: 卜加超
 * @Date: 2019/1/21 09:16
 * @Description:
 */
@Service
public class UserMessageSettingsDao {
    @Resource
    private SqlSession sqlSession;

    @Operate("strategy('byUserId', #userId)")
    public List<UserMessageSettings> selectUserMessageSettingsList(long userId) {
        return sqlSession.selectList("getUserMessageSettingsList",(int)userId);
    }

    @Operate("strategy('byUserId', #userId)")
    public UserMessageSettings selectUserMessageSettingsListByUserId(long userId) {
        return sqlSession.selectOne("getUserMessageSettingsById",userId);
    }

    @Operate("strategy('byUserId', #userId)")
    public void updateUserMessageByVoiceId(long userId, int showMessageId) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        params.put("showMessageId", showMessageId);
        sqlSession.update("updateUserMessageVoiceId",params);
    }
    @Operate("strategy('byUserId', #userId)")
    public void updateUserMessageByVideoId(long userId, int showMessageId) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        params.put("showMessageId", showMessageId);
        sqlSession.update("updateUserMessageVideoId",params);

    }
}
